public class MyValue {
    public int val;
    public static void swap(MyValue myValue1,MyValue myValue2){
        int tmp = myValue1.val;
        myValue1.val = myValue2.val;
        myValue2.val = tmp;
    }
    public static void main(String[] args){
        MyValue myValue1 = new MyValue();
        MyValue myValue2 = new MyValue();
        myValue1.val = 10;
        myValue2.val = 20;
        System.out.println("交换前的值:"+ myValue1.val + myValue2.val);
        swap(myValue1,myValue2);
        System.out.println("交换后的值:"+ myValue1.val + myValue2.val);
    }
}
